
#Title[ʏ4]
#Text[]
#Image[]
#BackGround[]
#BGM[]
#PlayLevel[Extra]
#ScriptVersion[2]
#Player[FREE]


script_enemy_main
{

	@Initialize
	{
	SetLife(4000);
	SetDamageRate(200,  100);
	SetTimer(60);
	SetInvincibility(250);
	SetEnemyMarker(true);
	SetGraphicRect(64,1,127,64);
	LoadGraphic("script\img\ExRumia.png");
	}
	//   ʒu܂ňړ
	SetMovePosition02(GetCenterX, GetCenterY-120, 60);

	AtackTaskA;
	AtackTaskB;
	MoveTask;
	@MainLoop
	{
		yield;

		SetGraphicRect(0,1,63,64);
		if(GetSpeedX<0){
			SetGraphicRect(128,1,191,64);
		}
		if(GetSpeedX>0){
			SetGraphicRect(192,1,255,64);
		}

		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 24);
	}
	
	@DrawLoop
	{
		SetColor(255,255,255);
		SetAlpha(255);
		SetTexture("script\img\ExRumia.png");//摜͔q
		DrawGraphic(GetX,GetY);
	}
		
	@Finalize
	{
		DeleteGraphic("script\img\ExRumia.png");
	}
	//XyJ[h̔wi
	//Ă悢
/*	@BackGround
	{
	}
*/
	task AtackTaskA{
		wait(120);
		let ammo=12;
		let nway=4;
		let dir=0;
		let rot=GetAngleToPlayer;
		while(true){
			let vx=rand(-3,3);
			let vy=rand(-3,0);
			loop(ammo){
				CreateShot12(cos(dir)*20+GetX,sin(dir)*20+GetY,vx,vy,0,0.05,0,10,GREEN01,20);
				dir+=360/ammo;
			}
			wait(5);
		}
	}
	task AtackTaskB{
		wait(120);
		let ammo=12;
		let dir=rand(0,360);
		while(true){
			loop(ammo){
				CreateShot01(cos(dir)*20+GetX,sin(dir)*20+GetY,3,GetAngleToPlayer,YELLOW01,20);
				dir+=360/ammo;
			}
			wait(50);
		}
	}

	task MoveTask{		//@Ɉړp^[
		wait(240);
		while(true){
			let ptn=0;
			if(GetX<GetCenterX-80){ptn=1;}
			if(GetX>GetCenterX+80){ptn=2;}
			if(ptn==0){
				if(GetX<GetPlayerX){ptn=1;}
				else{ptn=2;}
			}
			if(ptn==1){
				SetMovePosition02(rand(GetX+40,GetX+60), rand(GetClipMinY+80,GetCenterY-80), 40);
			}
			if(ptn==2){
				SetMovePosition02(rand(GetX-40,GetX-60), rand(GetClipMinY+80,GetCenterY-80), 40);
			}
			wait(150);
		}
	}

	function wait(n){
		loop(n){yield;}
	}

}

